#include<iostream>
#include<vector>
using namespace std;

class Solution {
public:
    bool areSentencesSimilar(string sentence1, string sentence2) {
        vector<string> s1, s2;
        string temp = "";
        for (int i = 0; i < sentence1.length(); i++) {
            if (sentence1[i] != ' ') {
                temp += sentence1[i];
            } else {
                s1.emplace_back(temp);
                temp = "";
            }
        } 
        s1.emplace_back(temp);
        temp = "";
        for (int i = 0; i < sentence2.length(); i++) {
            if (sentence2[i] != ' ') {
                temp += sentence2[i];
            } else {
                s2.emplace_back(temp);
                temp = "";
            }
        } 
        s2.emplace_back(temp);
        temp = "";
        vector<string>& long_s = (s1.size() > s2.size()) ? s1 : s2;
        vector<string>& short_s = (s1.size() > s2.size()) ? s2 : s1;
        int interval = long_s.size() - short_s.size();
        for (int i = 0; i < short_s.size(); i++) {
            if (short_s[i] != long_s[i]) {
                for (; i < short_s.size(); i++) {
                    if (short_s[i] != long_s[i + interval]) {
                        return false;
                    }
                }
                return true;
            }
        }
        return true;
    }
};

int main() {
    return 0;
}

/**
 * 2023.1.16
 * 模拟
*/